package com.beyondsoft.giinii.brie.jni;

import java.io.File;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

public class ShowImages extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fsresult);
        
        Intent intent = getIntent();
        filelist = intent.getStringArrayListExtra("filelist");

        GridView g = (GridView) findViewById(R.id.gridView1);
        g.setAdapter(new ImageAdapter(this));
	}
    
    public class ImageAdapter extends BaseAdapter 
    {
        public ImageAdapter(Context c) {
            mContext = c;
        }

        public int getCount() {
            return filelist.size();
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) 
        {
            ImageView imageView;
            if (convertView == null) 
            {
                imageView = new ImageView(mContext);
                imageView.setLayoutParams(new GridView.LayoutParams(100, 100));
                imageView.setAdjustViewBounds(false);
                imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
                imageView.setPadding(8, 8, 8, 8);
            } 
            else 
            {
                imageView = (ImageView) convertView;
            }
            imageView.setImageBitmap(BitmapFactory.decodeFile(filelist.get(position)));
            
            return imageView;
        }
        private Context mContext;
    }
    private ArrayList<String> filelist;
    private String filename;
}
